package cn.wetcland.urban.admin.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.wetcland.urban.admin.dto.NoticeAddDTO;
import cn.wetcland.urban.admin.dto.NoticeUpdateDTO;
import cn.wetcland.urban.admin.dto.OrderUpdateDTO;
import cn.wetcland.urban.admin.service.UtNoticeService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtNotice;
import cn.wetcland.urban.generator.domain.UtOrder;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Resource
    private UtNoticeService noticeService;

    @GetMapping("/noticeList")
    public AjaxResponse noticeList(BaseConditionSearchDTO searchDTO) {
        Page<UtNotice> noticePage = noticeService.noticeList(searchDTO);
        return AjaxResponse.success(noticePage);
    }

    @SaCheckLogin
    @PostMapping("/noticeAdd")
    public AjaxResponse noticeAdd(@RequestBody NoticeAddDTO addDTO) {
        noticeService.noticeAdd(addDTO);
        return AjaxResponse.success();
    }

    @PutMapping("/noticeUpdate")
    public AjaxResponse noticeUpdate(@RequestBody NoticeUpdateDTO updateDTO) {
        noticeService.noticeUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/noticeDelete/{noticeId}")
    public AjaxResponse noticeDelete(@PathVariable Long noticeId) {
        noticeService.noticeDelete(noticeId);
        return AjaxResponse.success();
    }

}
